/**
 * 函数防抖
 * @param fn 执行函数
 * @param delay 执行延迟
 * @returns 带防抖功能的函数
 */
export function useDebounce<T = any>(this: any, fn: (e?: T) => void, delay: number): (e?: T) => void {
  let timer: number
  return (...args) => {
    timer && window.clearTimeout(timer)
    timer = window.setTimeout(() => {
      fn.apply(this, args)
    }, delay)
  }
}
